class CardWindow extends Window_Selectable{
    
    constructor(...args){
        super(...args)
        window['$$cardWindow']=this
    }

    show(){
        super.show()
        this.showHelpWindow()
    }
    hide(){
        super.hide()
        this.hideHelpWindow()
    }

    maxCols(){
        return 2
    }
    costWidth(){
        return this.textWidth("000");
    }
    maxItems(){
        return this._data ? this._data.length : 1;
    }
    refresh(){
        this.makeItemList()
        super.refresh()
    }

    makeItemList(){
        this._data=$cardCtl.cardDatas
    }

    drawItem(index){
        let cardData=this._data[index]
        let skill=$dataSkills[cardData.skillId]
        const costWidth = this.costWidth();
        const rect = this.itemLineRect(index);
        //this.changePaintOpacity(this.isEnabled(skill));
        this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
        //this.drawSkillCost(skill, rect.x, rect.y, rect.width);
        //this.changePaintOpacity(1);
        
    }

    currentItem(){
        return this._data && this._index >= 0 ? this._data[this._index] : null
        
    }

    updateHelp(){
        let cardData=this.currentItem()
        if(cardData){
            let actor=$gameActors._data[cardData.ownerId]
            let skill=$dataSkills[cardData.skillId] 
            this._helpWindow.setText(`${actor?._name}   ${skill.name}`)
        }
        
    }
  
    // drawSkillCost(skill, x, y, width){
        
    //         this.drawText(this._actor.skillTpCost(skill), x, y, width, "right");
        
    // }
}